#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> coins(n);
  for (auto& x: coins) cin >> x;
  // vector<int> p1, p2;
  vector<vector<long long>> players(2);
  int currentPlayer = 0;
  while (!coins.empty()) {
    auto& player = players[currentPlayer];
    currentPlayer = (currentPlayer + 1) % 2;
    long long sum = 0;
    for (auto& x: player) sum += x;
    int index = -1;
    int mini = 0;
    for (int i = 0; i < coins.size(); i ++) {
      if (coins[i] <= sum) {
        if (index == -1 || coins[i] > coins[index]) {
          index = i;
        }
      }
      if (coins[i] < coins[mini]) {
        mini = i;
      }
    }
    if (index != -1) {
      player.push_back(coins[index]);
      coins.erase(coins.begin() + index);
    } else {
      player.push_back(coins[mini]);
      coins.erase(coins.begin() + mini);
    }
  }
  for (auto& player: players) {
    long long sum = 0;
    for (auto& x: player) sum += x;
    cout << sum << ' ';
  }
  cout << endl;
}